package com.artron.mediaartron.ui.fragment.detail;

import android.os.Bundle;
import android.support.v4.widget.NestedScrollView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;

import com.artron.baselib.base.BaseStaticFragment;
import com.artron.baselib.utils.ToastUtil;
import com.artron.mediaartron.R;
import com.artron.mediaartron.data.config.AppProfile;
import com.artron.mediaartron.ui.activity.CustomSelectionActivity;

import butterknife.BindView;
import rx.functions.Action0;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-09-21.
 */

public class PosterDetailFragment extends BaseStaticFragment {

    @BindView(R.id.PosterDetailFragment_fl_pic1)
    protected FrameLayout mFLPic1;
    @BindView(R.id.PosterDetailFragment_ns_content)
    protected NestedScrollView mNsContent;
    @BindView(R.id.PosterDetailFragment_btn_made)
    protected Button mBtnPosterMade;

    public static PosterDetailFragment newInstance() {
        Bundle args = new Bundle();
        PosterDetailFragment fragment = new PosterDetailFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_poster_detail;
    }

    @Override
    protected void initView() {
        mNsContent.post(new Runnable() {
            @Override
            public void run() {
                int height = mNsContent.getHeight();
                ViewGroup.LayoutParams params = mFLPic1.getLayoutParams();
                params.height = height;
                mFLPic1.setLayoutParams(params);
            }
        });

        mBtnPosterMade.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppProfile.getUserInfo().startLoginActivity(mContext, new Action0() {
                    @Override
                    public void call() {
                        CustomSelectionActivity.start(mContext,
                                CustomSelectionActivity.POSTER);
                    }
                });
            }
        });
    }

}
